/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**---
 description: >
    A type query obtains the type of an expression.A type query consists of the keyword typeof followed by an expression. 
    Type queries are useful for capturing anonymous types that are generated by letious constructs 
    such as object literals, function declarations, and namespace declarations.
 module: ESNext
 isCurrent: true
 ---*/


import { Assert } from '../../../../../suite/assert.js'

let a1: { x: number, y: string };
let a2: typeof a1;
a2 = {
    x: 10,
    y: 'y'
}
Assert.equal(typeof a2, 'object');

function b1(x: number, y: number): number { return x + y; }
let b2: typeof b1;
b2 = (x: number, y: number): number => { return x - y; }
Assert.equal(typeof b2, 'function');

namespace CC {
    export type C = keyof number & string;
}
let c1: CC.C;
let c2: typeof c1 = 'toExponential';
c2 = 'toString';
c1 = c2;
Assert.equal(c1, c2);

let c3: CC.C;
let c4: typeof c3[] = ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString', 'valueOf'];
Assert.equal(JSON.stringify(c4), '["toExponential","toFixed","toLocaleString","toPrecision","toString","valueOf"]');
